
# https://requests.readthedocs.io/projects/cn/zh-cn/latest/

import requests

url = 'https://www.mi.com/shop'

response = requests.get(url=url)
# print("类型:", type(response)) # 类型: <class 'requests.models.Response'>

# 设置编码
response.encoding = 'utf8'

html = response.text # 以字符串的形式返回网页源码
print(html)

# print(response.url)  # https://www.mi.com/shop

# print(response.content) # 返回二进制数据

# print(response.status_code) # 200 状态码

# print(response.headers) # 返回响应头
# {'Date': 'Fri, 24 Jan 2025 10:18:42 GMT',
# 'Content-Type': 'text/html; charset=UTF-8',
# 'Transfer-Encoding': 'chunked',
# 'Connection': 'keep-alive',
# 'Expires': 'Fri, 24 Jan 2025 10:19:02 GMT',
# 'Server': 'nginx', 'Cache-Control': 'max-age=60',
# 'Content-Encoding': 'gzip',
# 'Vary': 'Accept-Encoding, Origin, X-Is-Mobile-Viewer',
# 'X-Ser': 'i61976_c26719, i37786_c26269',
# 'X-Cache': 'HIT from i37786_c26269(cloudsvr)'}









